Imports DAL

Public Class frmReportPreview
    Public ReportName As String

    Private Sub frmReportPreview_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        'Rauhl_ITS@20073012 : Add following code display help
        Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Report Preview")
        e.Cancel = True
    End Sub

    Private Sub frmReportPreview_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If e.KeyCode = Keys.F1 Then
            'Rauhl_ITS@20073012 : Add following code display help
            e.SuppressKeyPress = True
            Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Report Preview")
        End If
    End Sub

    Private Sub frmReportPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dtbCounter As DataTable
        Try
            Call BCommon.SetFormStandards(Me)
            Call SetDatepickerMaxMinDate()
            Me.Text = BCommon.GetReportHeading(ReportName)
            Select Case ReportName
                Case "CounterSale"
                    lblVendor.Text = "&Select Counter"
                    dtbCounter = BCommon.GetCounter()
                    BCommon.SetComboValues(cmbVendor, dtbCounter, "CounterID", "CounterID")
                Case "VendorWiseSale", "VendorWiseStock"
                    lblVendor.Text = "&Vendor"
                    dtbCounter = BVendor.GetVendor()
                    BCommon.SetComboValues(cmbVendor, dtbCounter, "VendorID", "VendorName")
                Case "ItemWiseSale"
                    lblVendor.Text = "&Select Item"
                    dtbCounter = DItem.GetItem()
                    BCommon.SetComboValues(cmbVendor, dtbCounter, "ItemID", "ItemName")
            End Select

        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "frmReportPreview_Load")
        End Try
    End Sub
    'Divya 22/11/2007
    Private Sub SetDatepickerMaxMinDate()
        Dim dtDatePkr As DataTable
        Try
            dtDatePkr = BCommon.GetDatePicker()
            dtpFromDate.MinDate = dtDatePkr.Rows(0).Item("fin_start_dt")
            dtpFromDate.MaxDate = dtDatePkr.Rows(0).Item("fin_end_dt")
            dtpToDate.MinDate = dtDatePkr.Rows(0).Item("fin_start_dt")
            dtpToDate.MaxDate = dtDatePkr.Rows(0).Item("fin_end_dt")
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetDatepickerMaxMinDate")
        End Try
    End Sub
    Private Function ValidateData() As Boolean
        If dtpFromDate.Text > dtpToDate.Text Then
            BCommon.ShowMsgError(10244)
            Return False
        End If
        Return True
    End Function

    Private Sub btnOk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOk.Click
        'Dim Report As New Reports.frmReportViewer
        'Try
        '    If ValidateData() = False Then Exit Sub
        '    With Report
        '        ReDim .ParametersNames(3)
        '        ReDim .ParametersValues(3)
        '        .ParametersNames(0) = "FromDate"
        '        .ParametersValues(0) = dtpFromDate.Value.Date

        '        .ParametersNames(1) = "ToDate"
        '        .ParametersValues(1) = dtpToDate.Value.Date

        '        .ParametersNames(2) = "ProfitInAorP"
        '        .ParametersValues(2) = "A"
        '        Select Case ReportName
        '            Case "CounterSale"
        '                .ParametersNames(3) = "CounterID"
        '                If cmbVendor.SelectedValue > 0 Then
        '                    .ParametersValues(3) = cmbVendor.SelectedValue
        '                Else
        '                    .ParametersValues(3) = ""
        '                End If
        '            Case "VendorWiseSale", "ItemWiseSale"
        '                If ReportName = "VendorWiseSale" Then .ParametersNames(3) = "VendorID" Else .ParametersNames(3) = "ItemID"

        '                If cmbVendor.SelectedValue > 0 Then
        '                    .ParametersValues(3) = cmbVendor.SelectedValue
        '                Else
        '                    .ParametersValues(3) = 0
        '                End If
        '        End Select

        '        .Text = BCommon.GetReportHeading(ReportName)
        '        .ReportName = ReportName
        '        .ShowDialog()
        '    End With
        '    Me.Close()
        'Catch ex As Exception
        '    BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnOk_Click")
        'End Try

    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub
End Class